<!DOCTYPE html>
<html>
<head>
    <title>Parallel Plate Capacitor</title>
</head>
<body>
<canvas id="physicsCanvas" width="600" height="400" style="border:1px solid #000;"></canvas>
<script>
    const canvas = document.getElementById('physicsCanvas');
    const ctx = canvas.getContext('2d');
    
    // Clear canvas
    ctx.fillStyle = 'white';
    ctx.fillRect(0, 0, canvas.width, canvas.height);

    // Set default styles
    ctx.strokeStyle = 'black';
    ctx.fillStyle = 'black';
    ctx.lineWidth = 2;
    ctx.font = '20px Arial';
    ctx.textAlign = 'center';

    // Plate dimensions and positions
    const p1_x1 = 220, p1_y1_front = 93, p1_y2_front = 293;
    const p1_x2 = 260, p1_y1_back = 73, p1_y2_back = 273;
    const separation = 100;
    const p2_x1 = p1_x2 + separation;
    const p2_x2 = p2_x1 + (p1_x2 - p1_x1);

    // Draw Left Plate
    ctx.beginPath();
    ctx.moveTo(p1_x1, p1_y1_front);
    ctx.lineTo(p1_x1, p1_y2_front);
    ctx.lineTo(p1_x2, p1_y2_back);
    ctx.lineTo(p1_x2, p1_y1_back);
    ctx.closePath();
    ctx.stroke();
    
    // Draw Right Plate
    ctx.beginPath();
    ctx.moveTo(p2_x1, p1_y1_front);
    ctx.lineTo(p2_x1, p1_y2_front);
    ctx.lineTo(p2_x2, p1_y2_back);
    ctx.lineTo(p2_x2, p1_y1_back);
    ctx.closePath();
    ctx.stroke();

    // Draw Central Axis
    const y_axis_front = (p1_y1_front + p1_y2_front) / 2; // 193
    const y_axis_back = (p1_y1_back + p1_y2_back) / 2;   // 173
    const y_axis_dashed = (y_axis_front + y_axis_back) / 2; // 183
    
    // Solid line from left
    ctx.beginPath();
    ctx.moveTo(0, y_axis_front);
    ctx.lineTo(p1_x1, y_axis_front);
    ctx.stroke();

    // Dashed line between plates
    ctx.beginPath();
    ctx.setLineDash([5, 3]);
    ctx.moveTo(p1_x2, y_axis_dashed);
    ctx.lineTo(p2_x1, y_axis_dashed);
    ctx.stroke();
    
    // Solid line to the right
    ctx.beginPath();
    ctx.setLineDash([]);
    ctx.moveTo(p2_x2, y_axis_back);
    ctx.lineTo(canvas.width, y_axis_back);
    ctx.stroke();

    // Annotation for distance 'x'
    ctx.lineWidth = 1;
    const y_annot_line = 55;
    const y_annot_text = y_annot_line - 10;
    
    // Dashed vertical lines
    ctx.beginPath();
    ctx.setLineDash([3, 2]);
    ctx.moveTo(p1_x2, p1_y1_back);
    ctx.lineTo(p1_x2, y_annot_line);
    ctx.moveTo(p2_x1, p1_y1_front);
    ctx.lineTo(p2_x1, y_annot_line);
    ctx.stroke();
    
    // Horizontal line with arrowheads
    ctx.beginPath();
    ctx.setLineDash([]);
    ctx.moveTo(p1_x2, y_annot_line);
    ctx.lineTo(p2_x1, y_annot_line);
    // Left arrowhead
    ctx.moveTo(p1_x2 + 5, y_annot_line - 4);
    ctx.lineTo(p1_x2, y_annot_line);
    ctx.lineTo(p1_x2 + 5, y_annot_line + 4);
    // Right arrowhead
    ctx.moveTo(p2_x1 - 5, y_annot_line - 4);
    ctx.lineTo(p2_x1, y_annot_line);
    ctx.lineTo(p2_x1 - 5, y_annot_line + 4);
    ctx.stroke();

    // Text 'x'
    ctx.font = "italic 20px 'Times New Roman'";
    ctx.fillText('x', (p1_x2 + p2_x1) / 2, y_annot_text);

    // Label "metal plates"
    ctx.font = '20px Arial';
    ctx.textAlign = 'left';
    const label_x = 420;
    const label_y = 50;
    ctx.fillText("metal plates", label_x, label_y);
    
    // Leader lines for the label
    const leader_start_x = label_x - 5;
    const leader_start_y = label_y - 2;
    const mid_top_left_x = (p1_x1 + p1_x2) / 2;
    const mid_top_left_y = (p1_y1_front + p1_y1_back) / 2;
    const mid_top_right_x = (p2_x1 + p2_x2) / 2;
    const mid_top_right_y = (p1_y1_front + p1_y1_back) / 2;
    
    ctx.beginPath();
    ctx.moveTo(leader_start_x, leader_start_y);
    ctx.lineTo(mid_top_right_x, mid_top_right_y);
    ctx.moveTo(leader_start_x, leader_start_y);
    ctx.lineTo(mid_top_left_x, mid_top_left_y);
    ctx.stroke();
    
    // Figure Caption
    ctx.lineWidth = 2;
    ctx.textAlign = 'center';
    ctx.fillText("Fig. 6.1", canvas.width / 2, 380);

</script>
</body>
</html>